/*
 * SingleWayItem.java
 * business
 *
 * Created by ChenTao on 2017/2/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yidiandao.business.R;

/** 确认订单页面-支付方式/配送方式对应的一个单选Item */
public class SingleWayItem extends LinearLayout {

    private LinearLayout mllytWay;
    private CheckBox mCbChoose;
    private TextView mTvTitle;
    private View mLastLine;
    private View mFirstLine;

    public SingleWayItem(Context context) {
        this(context, null);
    }

    public SingleWayItem(Context context, AttributeSet attrs) {
        super(context, attrs);

        View root = LayoutInflater.from(context).inflate(R.layout.item_snigle_way, this, true);

        mFirstLine = root.findViewById(R.id.first_line);
        mLastLine = root.findViewById(R.id.last_line);
        mllytWay = (LinearLayout) root.findViewById(R.id.llyt_way);
        mCbChoose = (CheckBox) root.findViewById(R.id.cb_choose);
        mTvTitle = (TextView) root.findViewById(R.id.tv_title);
    }

    public void setFirstVisible() {
        mFirstLine.setVisibility(VISIBLE);
    }

    public void setLastVisible() {
        mLastLine.setVisibility(VISIBLE);
    }

    /** 设置Item的标题 */
    public void setTitle(String title) {
        mTvTitle.setText(title);
    }

    /** 设置是否选中 */
    public void setChecked(boolean checked) {
        mCbChoose.setChecked(checked);
    }
}
